#include "picture.h"
#include <QPixmap>
#include <QDateTime>
#include <QDebug>

Picture::Picture(QWidget *parent, QImage image, QString title, int time)
	: QWidget(parent), img(image), reason(title), snaptime(time)
{
	ui.setupUi(this);
	snaptime -= 8 * 3600;
	QDateTime qtime = QDateTime::fromTime_t(snaptime);
	QString ui_time = qtime.toString("yyyy-MM-dd hh:mm:ss");
	ui.reason->setText(reason);
	ui.time->setText(ui_time);
	ui.pic->setPixmap(QPixmap::fromImage(img).scaled(QSize(200, 200), Qt::KeepAspectRatio));
	connect(ui.pic, SIGNAL(show_clicked()), this, SLOT(show_picture()));
}

Picture::~Picture()
{
}

QString Picture::get_title()
{
	return ui.reason->text() + "    " + ui.time->text();
}

QImage Picture::get_image()
{
	return img;
}

void Picture::show_picture()
{
	emit show_list_pic(this);
}